package com.ferry.transport.netty.proxy;

import com.ferry.registry.domain.service.ServiceMetaData;
import com.ferry.serial.api.SerializerType;
import com.ferry.transport.netty.consumer.Connector;
import com.ferry.transport.netty.consumer.FailStrategy;
import com.ferry.transport.netty.consumer.LbType;
import com.ferry.transport.netty.invoker.AbstractProxyHandler;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;

/**
 * Created by daiyong
 */
public class JdkProxyHandler extends AbstractProxyHandler implements InvocationHandler {

	public JdkProxyHandler(String appName, ServiceMetaData serviceMetaData, int failoverRetries, FailStrategy failStrategy, LbType lbType, Connector connector, SerializerType serializerType) {
		super(appName, serviceMetaData, failoverRetries, failStrategy, lbType, connector, serializerType);
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		return doInvoke(method.getName(), args, true).get(3, TimeUnit.SECONDS);
	}
}
